package rank;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import data.RankPlayer;

public class RankGrade {
	public Set<RankPlayer> set = new HashSet<RankPlayer>();
	public Iterator<RankPlayer> randomIte = set.iterator();
	
	public void add(RankPlayer player) {
		set.add(player);
	}
	
	public void remove(RankPlayer player) {
		set.remove(player);
	}
	
	public void selectChallange(RankPlayer[] result, int from, int size) {
		int num = Math.min(set.size(), size);
		randomIte = set.iterator();
		for (int i = 0; i < num; i++) {
			result[from+i] = randomIte.next();
//			if (!randomIte.hasNext()) 
//				randomIte = set.iterator();
//			try {
//				result[from+i] = randomIte.next();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
		}
	}
}
